<template>
  <div class="app-container">
    <div class="filter-container">
      <span class="leftMar">用户名：</span>
      <el-input
        v-model="paramOrder.nickname"
        placeholder="请输入用户名"
        style="width: 200px"
        class="filter-item"
      />
      <span class="leftMar">提现状态：</span>
      <el-select
        v-model="paramOrder.cashOutStatus"
        clearable
        placeholder="请选择提现状态"
      >
        <el-option
          v-for="item in cashOutStatus"
          :key="item.key"
          :label="item.value"
          :value="item.key"
        >
        </el-option>
      </el-select>
      <!--  <span class="leftMar">时间选择：</span>
      <el-date-picker
        v-model="paramOrder.time"
        type="daterange"
        value-format="yyyy-MM-dd HH:mm:ss"
        range-separator="至"
        start-placeholder="开始日期"
        end-placeholder="结束日期"
      >
      </el-date-picker> -->
      <el-button
        class="filter-item"
        type="primary"
        icon="el-icon-search"
        @click="search"
      >
        搜索
      </el-button>
    </div>
    <el-table
      :data="dataList"
      v-loading="listLoading"
      border
      fit
      highlight-current-row
      style="width: 100%"
    >
      <el-table-column label="序号" width="80" align="center">
        <template slot-scope="scope">
          <span>{{ scope.$index + 1 }}</span>
        </template>
      </el-table-column>
      <el-table-column label="日期" align="center">
        <template slot-scope="{ row }">
          <span>{{ row.applicationTime }}</span>
        </template>
      </el-table-column>
      <!--   <el-table-column label="账号" align="center">
        <template slot-scope="{ row }">
          <span>{{ row.paymentTime }}</span>
        </template>
      </el-table-column> -->
      <el-table-column label="用户名" align="center">
        <template slot-scope="{ row }">
          <span>{{ row.nickname }}</span>
        </template>
      </el-table-column>
      <el-table-column label="提现金额(元)" width="250" align="center">
        <template slot-scope="{ row }">
          <span>{{ row.commissionAmount }}</span>
        </template>
      </el-table-column>
      <el-table-column label="状态" width="250" align="center">
        <template slot-scope="{ row }">
          <el-tag type="info" v-if="row.cashOutStatus == 'UNDER_REVIEW'"
            >审核中</el-tag
          >
          <el-tag type="success" v-if="row.cashOutStatus == 'ADOPT'"
            >通过</el-tag
          >
          <el-tag type="danger" v-if="row.cashOutStatus == 'REFUSE'"
            >拒绝</el-tag
          >
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center">
        <template slot-scope="{ row }">
          <el-button
            size="mini"
            type="primary"
            :disabled="row.cashOutStatus != 'UNDER_REVIEW'"
            @click="UpdateCashOutStatus(row, 'ADOPT')"
            >同意</el-button
          >
          <el-button
            size="mini"
            type="danger"
            :disabled="row.cashOutStatus != 'UNDER_REVIEW'"
            @click="UpdateCashOutStatus(row, 'REFUSE')"
            >拒绝</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      background
      layout="prev, pager, next"
      :page-size="10"
      :total="total_size"
      @current-change="changePage"
    >
    </el-pagination>
  </div>
</template>

<script>
const cashOutStatus = [
  {
    key: "",
    value: "全部",
  },
  {
    key: "UNDER_REVIEW",
    value: "审核中",
  },
  {
    key: "ADOPT",
    value: "通过",
  },
  {
    key: "REFUSE ",
    value: "未通过",
  },
];
import { GetWithdrawList, UpdateCashOutStatus } from "@/api/finance";
export default {
  name: "indent",
  data() {
    return {
      cashOutStatus, //状态
      total_size: 0, //多少条数据
      paramOrder: {
        //订单查询条件
        currPage: 1,
        pageSize: 20,
        cashOutStatus: "",
        nickname: "",
        time: ["", ""],
      },
      value1: "",
      listLoading: true, //加载
      dataList: [], //数据
    };
  },
  created() {
    this.getFinance();
  },
  methods: {
    search() {
      this.getFinance();
    },
    changePage(page) {
      console.log(page);
      this.paramOrder.currPage = page;
      this.getOrderList();
    },
    //获取财务列表
    getFinance() {
      GetWithdrawList(this.paramOrder).then((res) => {
        console.log(res);
        this.dataList = res.data.data_list;
        this.total_size = res.data.total_size;
        this.listLoading = false;
      });
    },
    //修改状态
    UpdateCashOutStatus(data, type) {
      UpdateCashOutStatus(data, type).then((res) => {
        if (res.code == 200) {
          this.$message.success("操作成功");
          this.getFinance();
        }
      });
    },
  },
};
</script>
<style scoped>
.leftMar {
  margin-left: 8px;
}
.filter-container {
  margin-bottom: 10px;
}
</style>